package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: BusinessStatusController
 * @Author: YuanDing
 * @Date: 2024/2/4 16:42
 * @Description:
 *  店铺相关设置
 */

@Api("店铺相关")
@RequestMapping("/admin/shop")
@RestController("adminShop")
public class ShopController {

    private static final String KEY = "SHOP_STATUS";

    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("获取店铺状态")
    @GetMapping("/status")
    public Result getShopStatus() {
        Integer shopStatus = (Integer)redisTemplate.opsForValue().get(KEY);
        return Result.success(shopStatus);
    }

    @ApiOperation("更新店铺状态")
    @PutMapping("/{status}")
    public Result setShopStatus(@PathVariable Integer status) {
        redisTemplate.opsForValue().set(KEY , status);
        return Result.success();
    }
}
